package com.example.memorypoint.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.memorypoint.fragment.DiaryFragment;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.memorypoint.R;

import java.util.List;

public class FragmentAdapter extends FragmentStatePagerAdapter {
    private List<DiaryFragment> list_fg;

    public FragmentAdapter(@NonNull FragmentManager fm, List<DiaryFragment> list) {
        super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.list_fg = list;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return list_fg.get(position);
    }

    @Override
    public int getCount() {
        return list_fg.size();
    }

    public void removeFragment(int position) {
        if (position >= 0 && position < list_fg.size()) {
            list_fg.remove(position);
            notifyDataSetChanged();
        }
    }

}




